<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="../../../lib/html5shiv.js?rev=@@hash"></script>
    <script type="text/javascript" src="../../../lib/respond.min.js?rev=@@hash"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="../../../lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../../ht-css/Project.css"/>
    <link rel="stylesheet" type="text/css" href="../../../lib/Validform/5.3.2/style.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="../../../lib/DD_belatedPNG_0.0.8a-min.js?rev=@@hash"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../../../ht-css/style-q.css"/>
    <title></title>
</head>
<body>
<form class="ml-20 mt-20 mb-20 mr-20" id="form-member-add">
    <table class="table table-border table-bg table-hover table-sort mt-10" id="datatable">
        <thead>
        <tr class="text-c">
            <th width="100">文件</th>
            <th width="50">上传账号</th>
            <th width="50">上传时间</th>
            <th width="50">操作</th>
        </tr>
        </thead>
        <tbody class="shun">

        </tbody>
    </table>
    <div style="text-align: center">
        <a onclick="cancelBtn()" id="cancelBtn" style="margin-top: 82px;" class="btn radius size-S ml-20">关闭</a>
    </div>
</form>
</body>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/layer/2.4/layer.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script>
<!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
<!--表单验证-->
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/messages_zh.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
<script src="../../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../../ht-js/verifyToken.js?rev=@@hash"></script>
<script src="../../../ht-js/Project.js?rev=@@hash"></script>
<script>
    sureBtns()
    function sureBtns() {
        var orderids=sessionStorage.getItem("orderid")
        $.ajax({
            url:root.orderInter.order_queryOrderDetails ,
            cache: false, //禁用缓存
            dataType: "json",
            type: "POST",
            data: {
                order_id: orderids, // 订单编号
            },
            success: function (result) {
                console.log(result)
                enclosureList(result.listOrderAttachment)
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                isIng = false;
            }
        });
    }
    /*表格渲染*/
    var dataSource = new Array();
    //table的数据源
    var table;   //table对象
    dataSource = [];

    function enclosureList(data) {
        dataSource.splice(0, dataSource.length);//清空数组

        $.each(data, function (i, field) {
            var rowData = new Array();
            rowData.push(field.attachment_url == null ? "" : field.attachment_url);
            rowData.push(field.login_account);
            rowData.push(field.created_at);
            rowData.push(field.attachment_name);
            dataSource.push(rowData);
        });
        initDataTable(dataSource);

        function initDataTable(dataSource) {
            var dttable = $('#datatable').dataTable(); // 初始化dataTable，清空上一个值
            dttable.fnClearTable(); //清空一下table
            dttable.fnDestroy(); //还原初始化了的datatable
            $("#datatable").DataTable({
                "order": [[ 1, "desc" ]],
                "autoWidth": false,
                "ordering": false,
                "searching": false,
                "paging": false,
                "retrieve": false,
                "destroy": false,
                "bAutoWidth": false,
                "bLengthChange": false,
                "aLengthMenu": [5, 10, 25, 50],
                "oLanguage": {
                    "sLengthMenu": "每页显示 _MENU_ 条记录",
                    "sZeroRecords": "抱歉， 没有找到",
                    "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
                    "sInfoEmpty": "没有数据",
                    "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
                    "oPaginate": {
                        "sFirst": "首页",
                        "sPrevious": "前一页",
                        "sNext": "后一页",
                        "sLast": "尾页"
                    },
                    "sZeroRecords": "没有检索到数据",
                    "sProcessing": "<img src='./loading.gif' />",
                },
                data: dataSource,
                columnDefs: [
                    {
                        "visible": true,
                        "targets": 0
                    },
                    {
                        "render": function (data, type, row, meta) {
                            let  str=row[0]
                            var index=str.lastIndexOf("\.");
                            str=str.substring(index+1,str.length);
                            console.log(str)
                            if(str=="docx"){
                                var val = '<span id="spuImg1" ><img  style="width: 50px;height: 57px;"  src="../../../img/Doc.png" width="80" height="40"></span>';
                                return val;
                            }else if(str=="pdf"){
                                var val = '<span id="spuImg1" ><img style="width: 50px;height: 57px;"  src="../../../img/Pdf.png" width="80" height="40"></span>';
                                return val;
                            }else if(str=="xlsx"){
                                var val = '<span id="spuImg1" ><img style="width: 50px;height: 57px;"   src="../../../img/Xls.png" width="80" height="40"></span>';
                                return val;
                            } else {
                                var val = '<span id="spuImg1" ><img  onclick="picShow(\'查看图片\',\'Enclosurepic.html\',\''+row[0]+'\')" src="'+row[0]+'" width="80" height="40"></span>';
                                return val;
                            }

                        },
                        "targets":0
                    },
                    {
                        "render": function (data, type, row, meta) {
                            var val = row[1]
                            if (val == undefined) {
                                val = ''
                            }
                            return val;
                        },
                        "targets": 1
                    },
                    {
                        "render": function (data, type, row, meta) {
                            var val = row[2]
                            if (val == undefined) {
                                val = ''
                            }
                            return val;
                        },
                        "targets": 2
                    },
                    {
                        "render": function (data, type, row) {
                            var val = '<a href="' +root.orderInter.downLoadFromUrl+'?urlStr='+encodeURIComponent(row[0])+'&fileName='+encodeURIComponent(row[3])+ '">下载</a>';
                            return val;
                        },
                        "targets": 3
                    }
                ]
            });
        };
    }


    function picShow(title, url, imgUrl) {

        sessionStorage.setItem("imgUrl", imgUrl);
        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);
    }
    //关闭
    function cancelBtn() {
        parent.layer.closeAll();
    }
</script>
</html>